package com.banciyuan.bcywebview.biz.pc;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.activity.BaseActivity;
import com.banciyuan.bcywebview.base.helper.ActionbarHelper;
import com.banciyuan.bcywebview.utils.string.StringUtil;

/**
 * Created by hy on 2015/6/10.
 */
public class TeamsActivity extends BaseActivity {
    private String uid;
    private String groupNum;
    private FragmentManager fragmentManager;
    private TeamsFragment mTeamsFragment;
    private ActionbarHelper mActionbarHelper;
    private View mActionBarView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_container);
        initArgs();
        initActionbar();
        getFragment();
    }

    private void getFragment() {
        fragmentManager = getSupportFragmentManager();
        mTeamsFragment = new TeamsFragment();
        Bundle bundle = new Bundle();
        bundle.putString("uid", uid);
        bundle.putBoolean("preLoad", true);
        mTeamsFragment.setArguments(bundle);
        if (!mTeamsFragment.isAdded()) {
            FragmentTransaction fts = fragmentManager.beginTransaction();
            fts.add(R.id.fragment_container, mTeamsFragment, "mTeamsFragment");
            fts.commit();
        }
    }

    @Override
    protected void initArgs() {
        Intent intent = getIntent();
        uid = intent.getStringExtra("uid");
        groupNum = intent.getStringExtra("groupNum");
    }

    @Override
    protected void initActionbar() {
        mActionBarView = findViewById(R.id.base_action_bar);
        mActionbarHelper = new ActionbarHelper(this, mActionBarView);
        if (!StringUtil.notNullEndWith(groupNum, "0")) {
            mActionbarHelper.setTitle(getString(R.string.teams_focus_title) + "(" + groupNum + ")");
        } else {
            mActionbarHelper.setTitle(getString(R.string.teams_focus_title));
        }
    }
}
